home *** CD-ROM | disk | FTP | other *** search
/ Workbench Design / WB Collection.iso / workbench werkzeuge / icon tools / makeicons / makeicons.ifx < prev    next >
Text File  |  1996-04-07  |  3KB  |  146 lines

  1. /*
  2.  * Arexx Macro for creating icons from images
  3.  * Created by Per Espen Hagen
  4.  * $VER: MakeIcons 1.5 (7.8.1994)
  5.  *
  6.  */
  7.  
  8. OPTIONS RESULTS
  9.  
  10. CALL AddLib("rexxreqtools.library", 0, -30, 0)
  11.  
  12.  
  13. /****** Get user input ******/
  14.  
  15. RollScreenUp 400
  16. CALL RTFileRequest(, , "Select image files", , "rtfi_flags=freqf_multiselect", InFiles)
  17. RollScreenDown
  18. IF InFiles ~= 1 THEN DO
  19.   RequestNotify "No files selected"
  20.   Exit
  21. END
  22.  
  23. /* Options requester */
  24. Gad.1 = 'J/80/17/25/Brightness:/0'
  25. Gad.2 = 'J/80/32/25/Contrast:/20'
  26. Gad.3 = 'J/80/47/25/Gamma:/30'
  27.  
  28. Gad.4 = 'J/180/17/25/Max Size:/80'
  29. Gad.5 = 'J/180/32/25/Step Size:/4'
  30. Gad.6 = 'J/180/47/25/Bitplanes:/3'
  31.  
  32. Gad.7 = 'X/230/17/Use Aspect?/1'
  33. Gad.8 = 'X/230/32/Colours?/1'
  34. Gad.9 = 'X/230/47/Lock GUI?/0'
  35.  
  36. ComplexRequest '"MakeIcons"' 9 Gad 345 83
  37.  
  38. Bri      = Result.1
  39. Con      = Result.2
  40. Gam      = Result.3
  41. MaxSize  = Result.4
  42. StepSize = Result.5
  43. Planes   = Result.6
  44. UseAsp   = Result.7
  45. Colours  = Result.8
  46. Lock     = Result.9
  47.  
  48.  
  49. /****** Convert & check input validity ******/
  50.  
  51. SELECT
  52.   WHEN Planes = 1 THEN NCol =   2
  53.   WHEN Planes = 2 THEN NCol =   4
  54.   WHEN Planes = 3 THEN NCol =   8
  55.   WHEN Planes = 4 THEN NCol =  16
  56.   WHEN Planes = 5 THEN NCol =  32
  57.   WHEN Planes = 6 THEN NCol =  64
  58.   WHEN Planes = 7 THEN NCol = 128
  59.   WHEN Planes = 8 THEN NCol = 256
  60. OTHERWISE
  61.   RequestNotify "Planes must be in the range 1-8"
  62.   Exit
  63. END
  64.  
  65.  
  66. /****** Initialize ImageFX ******/
  67.  
  68. /* Disable Undo, if enabled */
  69. GetPrefs Undo
  70. PrefUndo = Result
  71. SetPrefs Undo OFF
  72.  
  73. /* Set a few render options */
  74. Palette 8
  75. LockRange 0 OFF
  76. LoadPalette "Palettes/Workbench.palette" '-1'
  77. LockRange 0 ON
  78. Render Dither 1 0 0
  79. Render ModeID 692228
  80. Render Colors NCol
  81.  
  82.  
  83. /****** Main Loop ******/
  84.  
  85. DO FrameNo = 1 TO InFiles.count
  86.   IF Lock THEN LockGUI
  87.  
  88.   /* Load a picture */
  89.   LoadBuffer InFiles.FrameNo Force NOSMOOTH
  90.   
  91.   GetMain
  92.   IF Result = "" THEN DO
  93.     RequestNotify "Unable to load file. Out of memory?"
  94.   END
  95.   ELSE DO
  96.     Data = Result
  97.     PARSE VAR Data Name W H Depth AspX AspY Dummy
  98.  
  99.     /* Possible aspect adjustment */
  100.     IF UseAsp THEN DO
  101.       W = W * AspX
  102.       H = H * AspY
  103.     END
  104.  
  105.     IF W > H THEN DO
  106.       IconW = MaxSize
  107.       IconH = ((H*IconW/W + StepSize - 1) % StepSize) * StepSize
  108.     END
  109.     ELSE DO
  110.       IconH = MaxSize
  111.       IconW = ((W*IconH/H + StepSize - 1) % StepSize) * StepSize
  112.     END
  113.     Scale IconW IconH
  114.  
  115.     /* Convert to B/W, if desired */
  116.     IF Depth = 3 & ~Colours THEN
  117.       ColorToGray Luma
  118.  
  119.     /* Convert to colour, if necessary */
  120.     IF Depth = 1 THEN
  121.       GreyToColor
  122.     
  123.     /* Contrast enhancement */
  124.     Brightness Bri
  125.     Contrast Con
  126.     Gamma Gam
  127.  
  128.     /* Render the icon and save it */
  129.     Render Go
  130.     SaveRenderedAs Amiga InFiles.FrameNo FORCE
  131.     Render Close
  132.  
  133.     /* Add default tool to icon */
  134.     ADDRESS COMMAND
  135.     NewTool InFiles.FrameNo
  136.     ADDRESS
  137.  
  138.     /* Unlock GUI to give user some info what's happening */
  139.     UnlockGUI
  140.   END
  141. END
  142.  
  143. /* Reset Undo to previous state */
  144. SetPrefs Undo PrefUndo
  145.  
  146.